package com.hlxl.viewpoint.service.impl;

import com.hlxl.viewpoint.model.ViewPoint;
import com.hlxl.viewpoint.service.base.ViewPointLocalServiceBaseImpl;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.service.ServiceContext;

import java.util.ArrayList;
import java.util.List;

/**
 * The implementation of the view point local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.hlxl.viewpoint.service.ViewPointLocalService} interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see com.hlxl.viewpoint.service.base.ViewPointLocalServiceBaseImpl
 * @see com.hlxl.viewpoint.service.ViewPointLocalServiceUtil
 */
public class ViewPointLocalServiceImpl extends ViewPointLocalServiceBaseImpl {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never reference this interface directly. Always use {@link com.hlxl.viewpoint.service.ViewPointLocalServiceUtil} to access the view point local service.
     */

    public List<ViewPoint> getViewPoint(String name, int start, int end) throws SystemException {

        List<ViewPoint> viewPointList = viewPointPersistence.findByName("%" + name + "%", start, end);
        return viewPointList;
    }

    /**
     * Adds the view point to the database. Also notifies the appropriate model listeners.
     *
     * @param viewPoint the view point
     * @return the view point that was added
     * @throws SystemException if a system exception occurred
     */
    @Override
    public ViewPoint addViewPoint(ViewPoint viewPoint) throws SystemException {
        //todo add permission
        return super.addViewPoint(viewPoint);
    }

    public ViewPoint addViewPoint(ViewPoint viewPoint, ServiceContext serviceContext) throws SystemException {
        //todo add log
        addViewPoint(viewPoint);
        return viewPoint;
    }
}
